import request from "utils/request";
export const getArticlesAPI = (params) => {
  return request({
    url: "/v1_0/mp/articles",
    params,
  });
};

// 1. 封API
export const delArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: "DELETE",
  });
};

// 发布文章
// 1. API改造
export const publishArticleAPI = (data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: "POST",
    data,
  });
};

// 编辑文章
export const editArticleAPI = (data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles/${data.id}?draft=${draft}`,
    method: "put",
    data,
  });
};

// 文章详情
export const getArticleById = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: "get",
  });
};
